卡片是产品里最容易撞脸的元素。圆角、图标、标题、描述和一行 meta,几乎所有产品都能拼出相似的一组。

想让它有一点自己的性格,不必更换整个卡片系统。更克制的做法是:静止时完全保持原样,只有在悬停或键盘聚焦时,才像一本小书一样翻开一点,露出里面的几页。

静止时不能有任何变化

这个效果的前提是“藏”。卡片在静止状态下必须和原来的卡片一模一样:尺寸、内边距、文字、图标和布局都不变,周围元素也不能因为悬停而移动。

卡片本身的占位不参与 3D 运动。真正翻动的是内部图层:

1
封面 → 内页 1…N → 封底

封面承担原有卡片内容,内页和封底只是装饰,设置为 aria-hidden,不包含链接,也不进入 Tab 顺序。整张卡片仍然是一个完整的链接或按钮。

图层与铰链

封面、内页和封底都绝对定位在同一个方形区域内。外层容器提供约 1100px 的透视,铰链在左、右或上边缘,内部的每一层再使用相同的 transform-origin。

每个图层还需要一点 translateZ 偏移,避免翻开时互相打架:

1
translateZ((N + 1 - n) × 0.6px)

内页比封面向内缩 8px,靠书脊一侧再收 4px,圆角使用“封面圆角 − 8”。封底在平面卡片上向内缩约 6px,圆角同步减去 6;拟物风格则可以与封面齐平,并直接使用封面色的暗调。

扇形展开,而不是一起旋转

封面先动,后面的内页依次跟随。设封面为 n = 0,内页为 1…N:

1
2
角度 = 42° × 0.7ⁿ
延迟 = 28ms × n

每一层都用自己的弹簧收敛,大约 0.3 秒稳定。关闭时顺序反过来,最里面的页面先合上:

1
延迟 = 28ms × (N - n)

如果指针在动画中途离开,要从当前角度和速度重新设定目标,而不是回到起点重播。动作被打断时也不能跳帧。

项目没有弹簧工具时,可以用约 420ms 的 CSS 过渡近似,例如 cubic-bezier(0.3, 1.2, 0.5, 1)。

阴影要像实体,不能像描边

阴影是这类效果最容易露馅的部分。

不要用 box-shadow 画翻开的卡片阴影:它本质上是一圈中空的环,封面一旦离开原位,就会露出不自然的边框。

正确做法是在卡片后面放两层实心、预先模糊的阴影形状:

  • 接触阴影:较小、较深,贴着卡片底部;
  • 环境阴影:更淡、更柔,向下偏移。

静止时使用短而紧的一组;翻开时交叉淡入更长、更柔、更靠下的另一组。由于阴影已经预先模糊,动画只改变 opacity 和 transform,不逐帧修改模糊半径。

光源统一从上方来。阴影颜色应接近墙面,可以稍微偏暖或偏冷,但不要用纯黑,也不要用高饱和色。

每一页还需要一层“叶影”:前一页刚刚抬起时,后一页被压暗;两页分开后,再逐渐恢复亮度。这个明暗变化会让页面之间产生真实的间距感。

边缘和焦点属于同一套几何

封面、内页和封底必须共用同一套裁切路径。边框也应该沿着这条路径绘制,而不是混用 CSS border、inset shadow 和 clip-path——不同渲染方式在圆角处会出现第二道边。

如果要使用连续曲率,可以生成对应的超级椭圆路径,并让裁切和描边复用同一个路径。圆角、内页缩进和封底缩进都必须来自同一套 radius token。

交互命中区域要保持在卡片静止时的外框上。所有运动图层都设置 pointer-events: none,否则翻开的封面会在鼠标边缘来回触发,导致卡片抖动。

键盘聚焦应与悬停打开同样的状态,焦点环留在外层卡片上。开启减少动态效果时,取消扇形展开,只让封面轻轻抬起约 2px,并让阴影切换到翻开状态;触摸设备则确保第一次点击就能触发卡片,而不是把第一下点击只用来模拟悬停。

性能边界

只动画 transform 和 opacity。

不要动画 blur、box-shadow、clip-path、宽高或 top/left。阴影模糊只计算一次,之后交叉淡入淡出。

多张卡片共用一条 requestAnimationFrame 循环;弹簧静止的卡片跳过,所有卡片都停下时停止循环。每帧不读取布局,尺寸只在初始化和 ResizeObserver 触发时测量。

如果封面使用动态 ASCII 场景,画布最多约 30fps,并在离开屏幕或标签页隐藏时暂停。

三种视觉风格

同一套运动可以套进三种风格:

  • Default:普通产品卡片,白色表面、细边框、48px 图标、标题和描述;
  • Skeuomorphic:精装书,布纹封面、受光倒角、暖灰阴影、奶油色纸张;
  • Minimal:文档册,冷白或石墨色表面、等宽编号、细线图和灰色正文线。

风格只改变材质、排版和封面内容,不改变翻页的因果结构。卡片原有的 surface、border、shadow、radius 和 motion token 应优先复用。

翻页卡片示例 Prompt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
Make the cards in my product open a little, like a book, when hovered.
At rest a card must look exactly as it does today; only hover or focus
reveals that it is a small book with pages inside.

## 0. Start from what exists
- Find the card component I name (or the one used in the grid or list I
point to) and retrofit it in place. Reuse its markup, design tokens,
radius, shadow and motion or spring utilities.
- Keep the card's footprint, padding, content and layout unchanged.
Nothing around the card may move.
- If I ask for new cards instead, build a fresh square card (about
280 x 280) in the style I choose below.
- Any option I leave unset uses the default marked *.

## 1. Choose a style
Default*: ordinary product cards, identical to normal ones until hovered.
- Surface: plain white (or my card surface token), no texture.
- Edge: a 1px hairline in my border colour.
- Shadow: light, neutral cool grey, half strength.
- Type: the product sans. Title 24/600, description 15 muted,
meta 14 muted.
- Cover: the existing card UI: a 48px icon tile, a ↗ arrow top right,
title, description, and a meta footer below a hairline.
- Wall: my normal page background.
- Pages: white, a faint shade toward the spine, a small heading and
4-6 grey text lines.

Skeuomorphic: hardcover books on a gallery wall.
- Surface: fine bookcloth grain over a deep cover colour.
- Edge: a lit bevel: bright top edge, darker foot.
- Shadow: warm, near-neutral grey (never orange), full strength.
- Type: one serif title, bottom left. Nothing else on the cover.
- Cover: a full-bleed image or animated ASCII scene, with a soft gloss
at the top and shade at the foot.
- Wall: warm plaster with a fine grain and a spotlight over each book.
- Pages: cream paper with grain, an italic chapter heading, justified
lines, and thin page edges along the fore-edge.

Minimal: documentation volumes.
- Surface: flat off-white, light grey or graphite, one tone per card.
- Edge: a faint bevel or hairline.
- Shadow: cool neutral grey.
- Type: a mono section number and version on top, over a hairline rule;
a two-line sans title and a small grey label at the foot.
- Cover: one small grey line diagram with a single element in the ink
colour.
- Wall: cool grey with a faint 24px dot grid and soft light from above.
- Pages: cool white, a sans heading and grey lines.

Match my product: take surface, edge, shadow, type and wall from my
tokens, and keep the cover exactly as the card is today.

## 2. Options (defaults marked *)
- Intensity: subtle (A = 24deg) | book* (A = 42deg) | dramatic
(A = 60deg).
- Pages: 2 | 3 | 4* | 6.
- Hinge: left* | right | top.
- Trigger: hover* | press (open while pressed) | scroll into view (open
once when 60% visible, close after ~1.2s). Keyboard focus always
opens it too.
- Pages show: blank paper | lines of text* | real preview content from
the card (its next fields, a short list, a chart thumbnail).
- Cover: existing card UI* | image | animated ASCII scene | solid colour.
- Shadow direction: from above* | from top-left.
- Shadow strength: none | light | normal* | deep.
- Corners: match my tokens* | continuous (superellipse).
- Motion feel: snappy (k 320, damping 0.9) | default* (k 240,
damping 0.86) | soft (k 160, damping 0.8). All barely overshoot.
- Reduced motion: tiny lift* | nothing.
- Touch: press* | scroll into view | off.

## 3. Layer stack
- Inside the card's link, put the cover on a body element with
transform-style: preserve-3d. Behind it stack N pages and a back
board, all absolutely positioned on the same square.
- Order, front to back: cover (n = 0), pages (n = 1..N), back board
(n = N + 1, never moves).
- The cover keeps all of the card's existing content. Pages and the
back board are decorative: aria-hidden, no links, no tab stops.
- Perspective on the static outer element: about 1100px, origin toward
the hinge (30% 50% for left, 70% 50% for right, 50% 30% for top).
- transform-origin on the hinge edge of every layer: left 0 50%,
right 100% 50%, top 50% 0. backface-visibility: hidden.
- Lift layer n by translateZ((N + 1 - n) x 0.6px) so layers never
fight in depth.
- Pages sit 8px inside the cover (4px at the spine), like a book block,
with radius = cover radius - 8.
- Back board: on flat cards (Default, Minimal) inset it ~6px from the
cover with radius = cover radius - 6, so it never peeks out past the
cover's foreshortened corners. On Skeuomorphic it is flush, the cover
colour darkened ~28%.

## 4. Motion
- Layer n turns toward the viewer by
angle(n) = A x 0.7^n
and starts
delay(n) = 28ms x n
later. The cover leads; pages fan out behind it.
- Direction: rotateY(-angle) for a left hinge, rotateY(+angle) for
right, rotateX(+angle) for top.
- Each layer runs on its own spring (see Motion feel), settling in
about 0.3s.
- Close in reverse: the innermost page first, delay = 28ms x (N - n),
back to 0deg.
- If the pointer leaves mid-way, retarget from the current angle and
velocity. Never jump.
- No spring helper in the project? CSS transitions are fine: transition
transform over ~420ms with a slight overshoot, e.g.
cubic-bezier(0.3, 1.2, 0.5, 1), and set transition-delay to 28ms x n
in the open state and 28ms x (N - n) at rest (the target state's delay
applies, so closing runs in reverse).

## 5. Light and shading
- Light comes from above, so the shadow falls down the wall.
- The shadow is two solid shapes behind the card, each blurred once.
At rest it hugs the card like any flat card's:
- contact: small and darker, at the foot. Lower half of the card,
~4px in from each side, blur ~4px, ~2px down, ~22% opacity.
- ambient: faint. Blur ~14px, ~6px down, ~12% opacity.
- Never a box-shadow: it is a hollow ring and shows as an outline once
the cover swings off it.
- Tint: near-neutral grey nudged toward the wall (warm grey on a warm
wall, cool grey on a cool one). Never pure black, never saturated.
- Strength scales both opacities: light 0.5 (Default style), normal 1,
deep 1.4.
- Opening: crossfade to a second pre-blurred pair that is longer and
softer (contact blur ~12px, 12px down; ambient blur ~38px, 26px down),
and move it ~14px further down and ~4% wider with transform. Drive it
with one progress value o (0..1) on its own spring (k 200, damping
0.9): rest pair opacity 1 - o, open pair opacity o.
- Leaf shading: every page has an overlay gradient from the spine
(32% dark -> 8% at 55% -> 0 at 85%). Its opacity is
clamp(gap / 6, 0, 1) x max(0, 1 - gap / 30)
where gap = the angle of the leaf in front minus this leaf's angle.
A page is shaded while the leaf in front is just lifting off it, then
lit once they part.
- Covers (Skeuomorphic, Minimal): a soft gloss at the top edge and a
little shade at the foot.

## 6. Corners and edges
- Clip every layer (cover, pages, back board) to one shape path, and
draw its edge (hairline or bevel) along that exact path, e.g. an SVG
path stroked over the layer. Do not mix a CSS border or inset
box-shadow with the clip: they disagree at the corners and show a
second rim when the layers part.
- Match my tokens: use the token radius; nested radius = outer - inset.
- Continuous: superellipse corners |x|^n + |y|^n = 1 with n = 2^1.25
(the same curve as CSS corner-shape: superellipse(1.25)). Generate a
clip-path: path(...) per layer size, reuse it for the edge, and
regenerate on resize.

## 7. Interaction and accessibility
- Hit-test on the resting footprint: listen for hover on the static
outer element and give every moving layer pointer-events: none, so a
swinging cover never moves the target and the card never flickers
open and closed at its edges.
- Cursor: a pointing hand over the whole card.
- The whole card stays one <a> or <button> with its current accessible
name. Pages add nothing to the accessibility tree.
- :focus-visible opens it exactly like hover. Keep the focus ring on the
outer element, along the resting shape.
- Reduced motion: no fan and no rotation. The cover lifts ~2px and the
shadow crossfades to the open pair.
- Touch: no hover. Use the Touch option; a tap must still activate the
card on the first try.

## 8. Performance
- Animate transform and opacity only. Never animate blur, box-shadow,
clip-path, width, height or top/left.
- Never animate a blur radius: blur each shadow once and crossfade the
two pre-blurred versions.
- One requestAnimationFrame loop for all cards. Skip cards whose springs
are at rest, and stop the loop when nothing moves.
- Write a style only when its value changes (cache the last string per
element).
- No layout reads per frame: measure once, and again on resize
(ResizeObserver).
- Animated canvas ∂∂: draw at ~30fps at most, and pause when off
screen (IntersectionObserver) or when the tab is hidden.

## 9. Animated ASCII cover (only if chosen)
- Paint a small scene as one colour per character cell (~6 x 9px).
- Pick each character by brightness from " .:-=+*#%@".
- Draw a dimmed copy of the colours (~40%) underneath and the coloured
characters on top, so the gaps read like a halftone.
- Stamp characters from a pre-rendered glyph atlas instead of laying out
text every frame. Keep the motion slow and seamlessly looping.

## 10. When done
- List every file you changed or added.
- List the style and every option you used, marking which were
defaults.
- Note anything that no longer looks identical at rest.

质感来自可解释的细节

翻页卡片真正高级的地方,不是旋转角度有多大,而是静止时完全藏住、打开时每一层都有明确关系、关闭时还能顺手收回。

封面、页面、阴影、圆角和焦点共同遵守一套空间规则,卡片才会像一本可以拿起来的小书,而不是一组为了动而动的 3D 图层。

站内搜索

没有找到内容!